import React, {Component} from 'react';
import './App.css'
import {Route, Switch, Redirect} from 'react-router-dom'
import Home from "./pages/Home";
import About from "./pages/About";
import Header from "./components/Header";
import MyNavLink from "./components/MyNavLink";

class App extends Component {

    render() {
        return (
            <div>
                <Header/>
                <div className="row">
                    <div className="col-xs-2 col-xs-offset-2">
                        <div className="list-group">
                            {/*<a className="list-group-item" href="./about.html">About</a>
                            <a className="list-group-item active" href="./home.html">Home</a>*/}
                            {/*activeClassName="active" 点击样式——默认active*/}
                            <MyNavLink to='/about'>About</MyNavLink>
                            <MyNavLink to='/home'>Home</MyNavLink>
                        </div>
                    </div>
                    <div className="col-xs-6">
                        <div className="panel">
                            <div className="panel-body">
                                {/*Switch 匹配到对应地址后，不再向下匹配(比如下方path有2个及以上同样的值)*/}
                                <Switch>
                                    {/* exact 严格匹配 */}
                                    {/* 默认模糊匹配，to的值首段等于path则跳转，反之不可。 exact需要时再使用 */}
                                    <Route exact path='/about' component={About}/>
                                    <Route path='/home' component={Home}/>
                                    <Redirect to='/about'/>
                                </Switch>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        );
    }
}

export default App;